package com.ikingtech.framework.sdk.menu.api;

import com.ikingtech.framework.sdk.core.response.R;
import com.ikingtech.framework.sdk.menu.model.MenuDTO;
import com.ikingtech.framework.sdk.menu.model.RoleMenuAssignDTO;
import com.ikingtech.framework.sdk.web.annotation.PostRequest;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * @author tie yan
 */
public interface MenuApi {

    @PostRequest(order = 1, value = "/add", summary = "新增", description = "新增，新增成功后返回编号。")
    R<String> add(@Parameter(name = "menu", description = "菜单信息")
                  @RequestBody MenuDTO menu);

    @PostRequest(order = 2, value = "/delete", summary = "删除", description = "删除。")
    R<Object> delete(@Parameter(name = "id", description = "编号")
                     @RequestBody String id);

    @PostRequest(order = 3, value = "/update", summary = "更新", description = "更新。")
    R<Object> update(@Parameter(name = "menu", description = "菜单信息")
                     @RequestBody MenuDTO menu);

    @PostRequest(order = 5, value = "/list/all", summary = "全量查询", description = "全量查询，没有查询结果时返回空列表。")
    R<List<MenuDTO>> all();

    @PostRequest(order = 6, value = "/detail/id", summary = "查询详情", description = "查询详情，数据不存在时仍然返回成功,数据为null。")
    R<MenuDTO> detail(@Parameter(name = "id", description = "编号")
                      @RequestBody String id);

    @PostRequest(order = 7, value = "/list/role-id", summary = "查询菜单(角色编号)", description = "查询菜单(角色编号)，没有查询结果时返回空列表。")
    R<RoleMenuAssignDTO> listByRoleId(@Parameter(name = "roleId", description = "角色编号，仅支持传入一个角色编号")
                                      @RequestBody String roleId);

    @PostRequest(order = 9, value = "/list/login-user", summary = "查询菜单(登录用户)", description = "查询菜单(登录用户)，没有查询结果时返回空列表。")
    R<List<MenuDTO>> listByLoginUser();

    @PostRequest(order = 10, value = "/id/permission-code", summary = "根据授权码获取菜单编号", description = "根据授权码获取菜单编号。")
    R<String> getIdByPermissionCode(@RequestBody String permissionCode);
}
